package net.noday.demo.service;

import net.noday.demo.domain.User;
import net.noday.demo.service.impl.UserServiceImpl;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;

@ContextConfiguration("classpath:spring.xml")
public class UserServiceTest2 extends AbstractJUnit4SpringContextTests {
	
	//@Resource(name="userService")
	@Autowired//��ʱע��ʧ�ܲ�����
	private UserServiceImpl userService;
	
	@Test
	public void add() {
		User user = new User(0, "at19432163.com", "111111", "Noday", 
				"http://www.noday.net", "noday", 0, "noday", "1111-11-11", 
				"noday", true, "1111-11-11", "noday", null, "1111-11-11", "����");
		userService.add(user);
	}
	@Test
	public void get() {
		User u = userService.loadById(1);
		System.out.println(u.toString()+u.getUid()+u.getEmail());
	}
	@Test
	public void update() {
		User u = userService.loadById(5);
		u.setEmail("!@#");
		userService.update(u);
	}
	@Test
	public void delete() {
		userService.delete(10000);
	}
	@Test
	public void getAll() {
		for (User u : userService.getAll()) {
			System.out.println(u.getUid()+"|"+u.getEmail());
		}
	}
	@Test
	public void getAllByPage() {
		for (User u : userService.getAll(2, 4, 4, 3)) {
			System.out.println(u.getUid()+"|"+u.getEmail());
		}
	}
}
